<%@page import="cn.com.api.entity.ApiType"%>
<%@page import="java.util.List"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,member-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="css/pagination.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet"
	type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>优惠券管理</title>
</head>
<body>

	<div class="pd-5">
	<div class="cl bg-1 bk-gray"> 
		<form action="<%=path%>/backstage/select_coupons" method="get" class="form form-horizontal" id="form-select_coupons" onsubmit="beforSubmit()">
			<div class="text-c"> 
				<div class="mt-5 mb-5 cl">
					<div class="row cl">
						<label class="form-label col-2">标题：</label>
						<div class="formControls col-3">
							<input type="text" name="c_titles" value="${conditions.c_titles}" id="c_titles" placeholder="描述" class="input-text col-2">
							<input type="hidden" name="city_id" id="city_id" >
							<input type="hidden" name="act_type" id="act_type" value="${act_type }" >
							<input type="hidden" name="div_name" id="div_name" value="${div_name }" >
							<input type="hidden" name="num" id="num" value="${num }" >
						</div>
						
						<%-- <label class="form-label col-2"><span class="c-red">*</span>所属商铺：</label>
						<div class="formControls col-3">
							<span class="select-box">
								<select name="shop_id"  id="shops" class="select" datatype="n" nullmsg="请选择商铺">
									<option value="">所属商铺</option>
									<c:forEach items="${shops}" var="shop">
									<option value="${shop.cId}" <c:if test="${shop.cId==conditions.shop_id}">selected</c:if> >${shop.cSname}</option>
									</c:forEach>
								</select>
							</span>
						</div> --%>
					</div>
					<div class="row cl">
						<button name="" id="" class="btn btn-success f-r radius mr-20" type="submit"><i class="Hui-iconfont">&#xe665;</i> 查询</button>
					</div>
				</div>
			</div>
		</form>
		</div>


		<div class="mt-20">
			<table
				class="table table-border table-bordered table-hover table-bg table-sort">
				<thead>
					<tr class="text-c">
						<th width="40">ID</th>
						<th>标题</th>
						<th>使用商家</th>
						<th>消费金额</th>
						<th>优惠金额</th>
						<th>开始时间</th>
						<th>结束时间</th>
						<th>缩略图</th>
						<th width="100">操作</th>
					</tr>
				</thead>
				<tbody>
						<c:forEach items="${coupons_list}" var="coupon">		
						<tr class="text-c">
							<td>${coupon.c_id}</td>
							<td>${coupon.c_titles}</td>
							<td>
								<c:forEach items="${shops}" var="shop">
									<c:if test="${coupon.c_sid==shop.cId}">
										${shop.cSname}
									</c:if>
								</c:forEach>
							</td>
							<td>${coupon.expenditure}</td>
							<td>${coupon.cashed}</td>
							<td>${coupon.c_stime}</td>
							<td>${coupon.c_etime}</td>
							<td><img src="<%=imagePath%>${coupon.c_pname}" height="30" border="0" /></td>
							<td class="td-manage">
							<a style="text-decoration:none" onClick="searCoupons('${coupon.c_id}','${coupon.c_titles}','${coupon.expenditure }','${coupon.cashed }','${coupon.c_pname}')" href="javascript:;" title="选择">选择</a>
							</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
			<div id="Pagination" class="page-con"></div>
		</div>
	</div>
	<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="lib/layer/1.9.3/layer.js"></script>
	<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
	<script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript"
		src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="js/jquery.pagination.js"></script>
	<script type="text/javascript" src="js/H-ui.js"></script>
	<script type="text/javascript" src="js/H-ui.admin.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#cityid").val(parent.$("#cityid").val());
			$("#act_type_id").val(parent.$("#actid").val());
			initPager();
		});
		
		var showCount = ${pageInfo.showCount};
		var currentPage = ${pageInfo.currentPage-1};
		var totalResult = ${pageInfo.totalResult};
		function initPager(){
			$("#Pagination").pagination(totalResult, {
                callback: function(new_page_index, pagination_container){
                	var oldLocation = location.href;
                	var pa = "currentPage=" + (new_page_index+1);
            		var shoC = "showCount=" + showCount;
                	var index = oldLocation.lastIndexOf("?");
                	if (index == -1){
                		location.href = oldLocation + "?" + pa + "&" + shoC;
                	}else if (oldLocation.indexOf("currentPage") == -1){
                		location.href = oldLocation + "&" + pa;
                	}else if (oldLocation.indexOf("showCount") == -1){
                		location.href = oldLocation + "&" + shoC;
                	}else{
                		var temp = oldLocation.replace(/currentPage=\d+/, pa);
						var newLocation = temp.replace(/showCount=\d+/, shoC);
                		location.href = newLocation;
                	}
                	return false;
                },
                items_per_page:showCount, 
                load_first_page:false,
                prev_text:'上一页',
                next_text:'下一页',
                ellipse_text:'...',
                num_edge_entries:1,
                num_display_entries:5,
                current_page:currentPage
            });
		}
		
		
		function searCoupons(id,titles,expenditure,cashed,image){
			var index = parent.layer.getFrameIndex(window.name);
			var num=$("#num").val();
			var div_name = $("#div_name").val();
			parent.$('#'+div_name+num+'_c_id').val(id); 
			parent.$('#'+div_name+num+'_c_titles').val(titles); 
			parent.$('#'+div_name+num+'_expenditure').val(expenditure); 
			parent.$('#'+div_name+num+'_cashed').val(cashed); 
			parent.$('#'+div_name+'simg'+num).attr('src','<%=imagePath%>'+image); 
			parent.layer.close(index);
		}
	</script>
</body>
</html>